using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SimpleFramework
{
    public class ResSimplePool<T> where T : new()
    {
        private Stack<T> m_Stack;

        public ResSimplePool(int count)
        {
            m_Stack = new Stack<T>(count);
        }

        public T Spawn()
        {
            if (m_Stack.Count > 0)
            {
                return m_Stack.Pop();
            }
            else
            {
                var param = new T();
                return param;
            }
        }

        public void UnSpawn(T param)
        {
            m_Stack.Push(param);
        }
    }
}